﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ShortcutToolbox.View
{
    class TextAlignmentableGroupBox : GroupBox
    {
        //private string _Text = string.Empty;

        //public override string Text
        //{
        //    get { return _Text; }
        //    set { base.Text = string.Empty; _Text = value; }
        //}

        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            StringFormat s = new StringFormat();
            s.LineAlignment = StringAlignment.Near;
            s.Alignment = TextAlignment;
            SizeF textarea = e.Graphics.MeasureString(Text, Font);
            Brush a = new SolidBrush(BackColor);
            e.Graphics.FillRectangle(a, new RectangleF((Width - textarea.Width) / 2 + Padding.Left, Padding.Top, textarea.Width, textarea.Height));
            e.Graphics.DrawString(Text, Font, Brushes.Black, new RectangleF(Padding.Left, Padding.Top, Width, Height), s);
        }

        public StringAlignment TextAlignment { get; set; }
    }
}
